package com.qef.com.mmovie.presenter;


import com.orhanobut.logger.Logger;
import com.qef.com.mmovie.api.VideoListBean;
import com.qef.com.mmovie.entity.VideoPlayEntity;
import com.qef.com.mmovie.entity.VideoTopEntity;
import com.qef.com.mmovie.mvp.interactor.VideoInteractor;
import com.qef.com.mmovie.mvp.interactor.VideoTopInteractor;
import com.qef.com.mmovie.net.IGetDataDelegate;
import com.qef.com.mmovie.presenter.contract.VideoHomeContract;
import com.qef.com.mmovie.presenter.contract.VideoTopHomeContract;

import javax.inject.Inject;

import io.reactivex.disposables.Disposable;


/**
 * Created by qianenfan on 17/2/24.
 */

public class VideoTopHomePresenter extends RxPresenter<VideoTopHomeContract.View> implements VideoTopHomeContract.Presenter {
    //    private KyApiService mRetrofitHelper;
    @Inject
    VideoTopInteractor videoInteractor;

    @Inject
    public VideoTopHomePresenter() {
    }

    @Override
    public void getVideoData(int page) {
        Disposable disposable = videoInteractor.loadTopPlayList(page, new IGetDataDelegate<VideoTopEntity>() {

            @Override
            public void getDataSuccess(VideoTopEntity videoTopEntity) {
                mView.showContent(videoTopEntity);
            }

            @Override
            public void getDataError(Throwable throwable) {
                mView.error(throwable);
            }
        });
        addSubscrebe(disposable);
    }

    @Override
    public void getVideoPlayUrl(String id) {
        Disposable disposable = videoInteractor.loadVideoPlay(id, new IGetDataDelegate<VideoPlayEntity>() {
            @Override
            public void getDataSuccess(VideoPlayEntity videoPlayEntity) {
                mView.playVideo(videoPlayEntity);
            }

            @Override
            public void getDataError(Throwable throwable) {
                mView.error(throwable);
            }
        });
        addSubscrebe(disposable);
    }

}
